﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace SingletonClient
{
    class Program
    {
        static void Main(string[] args)
        {
            Ronson.Ronsoninstance.ShowName();
            Ronson.Ronsoninstance.ShowName();
        }
    }
    class Ronson
    {
        private Ronson()
        {
            Console.WriteLine("开始创建ronson");
            Thread.Sleep(5000);
            Console.WriteLine("ronson创建完成");
        }
        private static Ronson _ronsonInstance;
        private static readonly object _lockObj = new object();
        public static Ronson Ronsoninstance
        {
            get
            {
                lock (_lockObj)
                {
                    if (_ronsonInstance == null)
                    {
                        _ronsonInstance = new Ronson();
                    }
                }
              
                return _ronsonInstance;
            }
        }
        public void ShowName()
        {
            Console.WriteLine("我是Ronson");
        }

    }
}
